- 1.49.0 (latest)
- 1.48.0
- 1.47.0
- 1.46.0
- 1.45.0
- 1.44.0
- 1.43.0
- 1.42.0
- 1.41.0
- 1.39.0
- 1.38.0
- 1.37.0
- 1.36.0
- 1.35.0
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.26.0
- 1.25.0
- 1.24.0
- 1.23.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.6
- 1.4.0
- 1.3.2
- 1.2.12
com.google.cloud.resourcemanager
A client for Cloud Resource Manager - Centrally manage all your projects, IAM, and resource containers.
Here's a simple usage example for using google-cloud from App/Compute Engine. This example creates a project if it does not exist. For the complete source code see GetOrCreateProject.java.
ResourceManager resourceManager = ResourceManagerOptions.getDefaultInstance().getService();
String projectId = "my-globally-unique-project-id"; // Change to a unique project ID.
Project project = resourceManager.get(projectId);
if (project == null) {
project = resourceManager.create(ProjectInfo.builder(projectId).build());
}
System.out.println("Got project " + project.getProjectId() + " from the server.");
This second example shows how to update a project if it exists and list all projects the user has permission to view. For the complete source code see UpdateAndListProjects.java.
ResourceManager resourceManager = ResourceManagerOptions.getDefaultInstance().getService();
Project project = resourceManager.get("some-project-id"); // Use an existing project's ID
if (project != null) {
Project newProject = project.toBuilder()
.addLabel("launch-status", "in-development")
.build()
.replace();
System.out.println("Updated the labels of project " + newProject.getProjectId()
+ " to be " + newProject.getLabels());
}
Iterator<Project> projectIterator = resourceManager.list().iterateAll();
System.out.println("Projects I can view:");
while (projectIterator.hasNext()) {
System.out.println(projectIterator.next().getProjectId());
}
Remember that you must authenticate using the Google Cloud SDK. See more about providing credentials here. See Also: Google Cloud Resource Manager
com.google.cloud.resourcemanager.spi
com.google.cloud.resourcemanager.spi.v1beta1
com.google.cloud.resourcemanager.testing
A testing helper for Google Cloud Resource Manager.
A simple usage example: Before the test:
LocalResourceManagerHelper resourceManagerHelper = LocalResourceManagerHelper.create();
resourceManagerHelper.start();
ResourceManager resourceManager = resourceManagerHelper.getOptions().getService();
After the test:
resourceManagerHelper.stop();
com.google.cloud.resourcemanager.v3
A client to Cloud Resource Manager API
The interfaces provided are listed below, along with usage samples.
FoldersClient
Service Description: Manages Cloud Platform folder resources. Folders can be used to organize the resources under an organization and to control the policies applied to groups of resources.
Sample for FoldersClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (FoldersClient foldersClient = FoldersClient.create()) {
FolderName name = FolderName.of("[FOLDER]");
Folder response = foldersClient.getFolder(name);
}
OrganizationsClient
Service Description: Allows users to manage their organization resources.
Sample for OrganizationsClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (OrganizationsClient organizationsClient = OrganizationsClient.create()) {
OrganizationName name = OrganizationName.of("[ORGANIZATION]");
Organization response = organizationsClient.getOrganization(name);
}
ProjectsClient
Service Description: Manages Google Cloud Projects.
Sample for ProjectsClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ProjectsClient projectsClient = ProjectsClient.create()) {
ProjectName name = ProjectName.of("[PROJECT]");
Project response = projectsClient.getProject(name);
}
TagBindingsClient
Service Description: Allow users to create and manage TagBindings between TagValues and different Google Cloud resources throughout the GCP resource hierarchy.
Sample for TagBindingsClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (TagBindingsClient tagBindingsClient = TagBindingsClient.create()) {
ResourceName parent = FolderName.of("[FOLDER]");
for (TagBinding element : tagBindingsClient.listTagBindings(parent).iterateAll()) {
// doThingsWith(element);
}
}
TagHoldsClient
Service Description: Allow users to create and manage TagHolds for TagValues. TagHolds represent the use of a Tag Value that is not captured by TagBindings but should still block TagValue deletion (such as a reference in a policy condition). This service provides isolated failure domains by cloud location so that TagHolds can be managed in the same location as their usage.
Sample for TagHoldsClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (TagHoldsClient tagHoldsClient = TagHoldsClient.create()) {
TagValueName parent = TagValueName.of("[TAG_VALUE]");
TagHold tagHold = TagHold.newBuilder().build();
TagHold response = tagHoldsClient.createTagHoldAsync(parent, tagHold).get();
}
TagKeysClient
Service Description: Allow users to create and manage tag keys.
Sample for TagKeysClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (TagKeysClient tagKeysClient = TagKeysClient.create()) {
TagKeyName name = TagKeyName.of("[TAG_KEY]");
TagKey response = tagKeysClient.getTagKey(name);
}
TagValuesClient
Service Description: Allow users to create and manage tag values.
Sample for TagValuesClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (TagValuesClient tagValuesClient = TagValuesClient.create()) {
TagValueName name = TagValueName.of("[TAG_VALUE]");
TagValue response = tagValuesClient.getTagValue(name);
}